#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<vector>


struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};
 

using namespace std;
class Solution {
public:
    void createTree(int left, int right, int& index, vector<int>& preorder, vector<int>& inorder, TreeNode*& root)
    {
        if (left > right)
            return;
        int target;
        for (int i = left; i <= right; i++)
        {
            if (preorder[index] == inorder[i])
            {
                target = i;
                break;
            }
        }
        root = new TreeNode(preorder[index]);
        index++;
        createTree(left, target - 1, index, preorder, inorder, root->left);
        createTree(target + 1, right, index, preorder, inorder, root->right);
        return;
    }
    TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
        TreeNode* root = nullptr;
        int n = 0;
        createTree(0, inorder.size() - 1, n, preorder, inorder, root);
        return root;
    }
};


int main()
{
    
    return 0;
}
